home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
c
/
commasm.zip
/
COMM-ASM.MSG
next >
Wrap
Text File
|
1988-07-13
|
25KB
|
718 lines
Article 5187 of comp.sys.ibm.pc:
Path: cgh!vu-vlsi!cbmvax!rutgers!ames!ucbcad!ucbvax!hoptoad!pozar
From: pozar@hoptoad.uucp (Tim Pozar)
Newsgroups: comp.lang.c,comp.sys.ibm.pc
Subject: Re: C code for opening a communications file
Message-ID: <3731@hoptoad.uucp>
Date: 25 Dec 87 16:39:42 GMT
References: <621@umbc3.UMD.EDU>
Reply-To: pozar@hoptoad.UUCP (Tim Pozar)
Organization: Syncstream/Widget Systems (San Francisco)
Lines: 704
Xref: cgh comp.lang.c:2667 comp.sys.ibm.pc:5187
In article <621@umbc3.UMD.EDU> dipto@umbc3.umd.edu (Dipto Chakravarty) writes:
>
>Expertise needed to open a communications file (COM1) on an IBM PC !!!!!!
>
>My fellow C-pals, I need your help to get an equivalent of the following
>BASICA code. This code in BASICA works fine as an experiment. However, in
>real life, I am required to implement the following in Microsoft C 4.0,
>for a communications program.
>
>100 OPEN "COM1:9600, N, 8, 1, RS, CS, DS, CD" AS #1
>
>Above given is the line which opens COM1. The IBM BASIC manual will have
>the detailed descriptions of the options used. For my friends who aren't
>in touch with the finer details of BASIC syntax here is a short summary
>of the options used in the above statement.
>
>OPEN opens an asynchronous communications file
>COM1 communications port 1
>9600 speed; specifying the transmit/receive bit rate in bits/sec (bps)
>N specifies that there is no Xmit parity; no receive parity checks
>8 specifies the number of transmit/receive data bits
>1 specifies the number of stop bits
>RS suppreses RTS (Request To Send)
>CS this option allows user to ignore this line
>DS this option allows user to ignore this line
>CD this option allows user to ignore the Carrier Detect checks
>
Ok, folks here it is. I've been holding off on posting this
for more than a year for fear of riticule for the sloppy code.
This is an asm source communications functions to be linked in
with MSC 3.0 to 5.0. This is only here to see how asm is linked
in with MSC and to see how interupt handlers work. If anyone is
planning to seriously get into communications routines, I would
suggest the FOSSIL drivers, NOT this code. Also look carfully
at the code before using it. This is an old version and I think
the resettty() is not fully functional...
---
/*
* Comport.h
*
* defines the bit masking for the get_mcr()
*
* Copyright (C) Tim M. Pozar 1987
*
*/
/*
* get_msr()
* Function to read (get) the byte located in the Modem Status
* Register (3FEh). The table below describes the byte returned.
* bit description
* 0 Delta Clear to Send (DCTS)
* Indicates that the !CTS input to the chip has changed state
* since the last time it was read by the processor.
* 1 Delta Data Set Ready (DDSR)
* Indicates that the !DRS input to the chip has changed since
* last time it was read by the processor.
* 2 Trailing Edge Ring Indicator (TERI)
* Indicates that the !RI input to the chip has changed from
* an on (logical 1) to an off (logical 0) condition.
* 3 Delta Rx Line Signal detect (DRLSD)
* Indicates that the !RLSD input to the chip has changed state.
* NOTE: Whenever bit 0, 1, 2, or 3 is set to a logical 1, a modem status
* interrupt is generated.
*
* 4 Clear to Send (CTS)
* This bit is the complement of the clear to send (!CTS) input.
* If bit 4 (LOOP) of the MCR is set to a logical 1, this is
* equivalent to RTS in the MCR.
* 5 Data Set Ready (DSR)
* This bit is the complement of the data set ready (!DSR) input.
* If bit 4 (LOOP) of the MCR is set to a logical 1, this is
* equivalent to DTR in the MCR.
* 6 Ring Indicator (RI)
* This bit is the complement of the ring indicator (!RI) input.
* If bit 4 (LOOP) of the MCR is set to a logical 1, this is
* equivalent to OUT 1 in the MCR.
* 7 Receive Line Signal Detect (RLSD) or Carrier Detect (CD).
* This bit is the complement of the received line signal detect
* (!RLSD) input. If bit 4 (LOOP) of the MCR is set to a logical 1,
* this is equivalent to OUT 2 in the MCR.
*/
#define DCTS 1
#define DDSR 2
#define TERI 4
#define DRLSD 8
#define CTS 16
#define DST 32
#define RI 64
#define RLSD 128 /* Also know as ... */
#define CD 128
---
... and the asm code...
---
title IBM PC Communications I/O Routines
;
; Orginal code -- Curt Klinsing
;
; Changes and updates -- Copyright (c) 1987 Tim Pozar
;
; ver: 0
; rev: 2
; March 13th 1987
; This code is in a very early stage and should not be let out.
; Several other extensive functions are planned as well as changes
; to the current code.
;
; 2/20/87
; Changed segment declarations and function names (eg. _function)
; to fit Microsoft C 4.0 and linker requirements.
;
; FUNCTIONS CHANGED/ADDED --
; set_tty(port_number)
; Function to find current settings of the port and set up serial
; port for 'baud' and 'lcbyte', and enable DTR. This will set up the
; port number base addressed passed to it (eg. 3F8h) and all functions
; will use this port until the function is used again. (NOT READY FOR USE)
;
; reset_tty()
; Function to put the port back into the state it was when it was
; first found by set_tty(). If set_tty() was not called it will not
; change the settings of the port. (NOT READY FOR USE)
;
; 3/13/87
; get_msr()
; Function to read (get) the byte located in the Modem Status
; Register (3FEh). The table below describes the byte returned.
; bit description
; 0 Delta Clear to Send (DCTS)
; Indicates that the !CTS input to the chip has changed state
; since the last time it was read by the processor.
; 1 Delta Data Set Ready (DDSR)
; Indicates that the !DRS input to the chip has changed since
; last time it was read by the processor.
; 2 Trailing Edge Ring Indicator (TERI)
; Indicates that the !RI input to the chip has changed from
; an on (logical 1) to an off (logical 0) condition.
; 3 Delta Rx Line Signal detect (DRLSD)
; Indicates that the !RLSD input to the chip has changed state.
; NOTE: Whenever bit 0, 1, 2, or 3 is set to a logical 1, a modem status
; interrupt is generated.
;
; 4 Clear to Send (CTS)
; This bit is the complement of the clear to send (!CTS) input.
; If bit 4 (LOOP) of the MCR is set to a logical 1, this is
; equivalent to RTS in the MCR.
; 5 Data Set Ready (DSR)
; This bit is the complement of the data set ready (!DSR) input.
; If bit 4 (LOOP) of the MCR is set to a logical 1, this is
; equivalent to DTR in the MCR.
; 6 Ring Indicator (RI)
; This bit is the complement of the ring indicator (!RI) input.
; If bit 4 (LOOP) of the MCR is set to a logical 1, this is
; equivalent to OUT 1 in the MCR.
; 7 Receive Line Signal Detect (RLSD).
; This bit is the complement of the received line signal detect
; (!RLSD) input. If bit 4 (LOOP) of the MCR is set to a logical 1,
; this is equivalent to OUT 2 in the MCR.
;
; Currently this driver is set up for COM1 (3f8h).
; If you are using the interupt driven buffer, take out the code
; that enables the DTR so that it doesn't get raised until the vectors
; are initilized.
;
_TEXT SEGMENT BYTE PUBLIC 'CODE'
_TEXT ENDS
_DATA SEGMENT BYTE PUBLIC 'DATA'
_DATA ENDS
CONST SEGMENT BYTE PUBLIC 'CONST'
CONST ENDS
_BBS SEGMENT BYTE PUBLIC 'BBS'
_BBS ENDS
DGROUP GROUP CONST, _BBS, _DATA
ASSUME CS: _TEXT, DS: DGROUP, SS: DGROUP, ES: DGROUP
_TEXT SEGMENT
;
;A set of Lattice C and MSC callable functions to support
;interrupt driven character I/O on the IBM PC. Input
;is buffered, output is polled.
;
;added functions (TMP) --
public _set_tty ;find current